<?php

namespace App\Http\Controllers;

use App\Drawer;
use Carbon\Carbon;
use Illuminate\Http\Request;

class DrawerController extends Controller
{
    //抽屉列表页面
    public function index()
    {
        $drawers = Drawer::where('is_active', 1)->paginate(21);

        return view('drawer/index', compact('drawers'));
    }

    /**
     * 展示对应的抽屉信息
     * @date 2017/7/23
     * @param $drawer
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function show(Drawer $drawer)
    {
        return view('drawer/show', compact('drawer'));
    }

    public function add()
    {
        $info = [
            'user_id'   => 1,
            'name'      => 'test' .rand(1, 100),
            'intro'     => 'intro' . rand(1, 1000)
        ];
        $drawer = new Drawer();
        $drawer->user_id = 1;
        $drawer->name = 'test'.rand(1, 100);
        $drawer->intro = 'intro' . rand(1, 10000);

        $drawerId = $drawer->save($info);
        dd($drawerId);
    }
    //抽屉分类展示页面
    public function category($id)
    {

    }

    //抽屉列表页面，展示的是商品
    public function detail()
    {

    }

    //创建抽屉
    public function create()
    {

    }
}
